package br.com.nuccitec.jfera.basic;

import br.com.nuccitec.jfera.api.IRemoteResponse;
import br.com.nuccitec.jfera.business.AbstractBusinessExecutor;
import br.com.nuccitec.jfera.business.BusinessResponse;
import br.com.nuccitec.jfera.business.IBusinessPrefixExecutor;
import br.com.nuccitec.jfera.validation.vo.AbstractVO;

public class GenericSaveExecutor extends AbstractBusinessExecutor implements IBusinessPrefixExecutor {
	static private final String SAVE_PREFIX = "SAVE";

	@Override
	public String requestPrefixToAttend() {
		return SAVE_PREFIX;
	}

	@Override
	public IRemoteResponse execute(Object objVO) {
		AbstractVO a = (AbstractVO) objVO;
		a.setColaborator(getColaborator());
		getColaborator().logInfo(getClass(), "Saving " + a);
		a.save();
		return new BusinessResponse(a);
	}
}
